package cn.zhengzhou.springbootmybatis.demo;

import cn.zhengzhou.springbootmybatis.pojo.Student;
import org.apache.ibatis.javassist.compiler.ast.Variable;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;

public class LamdbaDemo {
    public static void main(String[] args) {
        Student[] s=new Student[6];
        s[0] = new Student("1","殷素素",18,"男");
        s[1] = new Student("7","杨幂",4,"女");
        s[2] = new Student("5","张无忌",9,"男");
        s[3] = new Student("9","小昭",2,"男");
        s[4] = new Student("3","赵敏",3,"女");
        s[5] = new Student("2","刘亦菲",23,"女");

        /*Arrays.sort(s,new Comparator<Student>() {

            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()-o2.getAge();
            }
        });*/
        Arrays.sort(s,( o1,  o2) -> {
//            return o1.getName().compareToIgnoreCase(o2.getName());
            return Integer.parseInt(o1.getId())-Integer.parseInt(o2.getId());
        });

        for (int i = 0; i < s.length; i++) {
            Student student = s[i];
            System.out.println(student);
        }
    }

}
